package com.econ.powercloud.ems.controller;

import com.econ.powercloud.common.base.facade.pojo.MsgResult;
import com.econ.powercloud.console.facade.domain.CloudControlVO;
import com.econ.powercloud.ems.aop.UserOperatePower;
import com.econ.powercloud.ems.service.biz.CloudControlBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author : zjf
 * @Description :
 * @Date : 2022/8/5 16:35
 * @Modified by : zjf
 */
@Api(tags = "云端设置")
@RestController
@RequestMapping(value = "/api/v2/cloud/control")
public class CloudControlController extends ApiBaseController{

    @Autowired
    private CloudControlBizService cloudControlBizService;

    @ApiOperation(value = "获取云端设置信息")
    @GetMapping
    public MsgResult<CloudControlVO> search(){
        return this.successHandler(cloudControlBizService.getCloudControlInfo());
    }

    @UserOperatePower
    @ApiOperation(value = "下发云端控制")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "onoff", value = "下发状态", dataType = "int")
    })
    @PostMapping("/push/cloudSwitch")
    public MsgResult<Integer> cloudSwitch(@RequestParam Integer onoff) {
        return this.successHandler(cloudControlBizService.pushCloudSwitch(onoff));
    }

}
